Notifications
Clear all

[Solved] How to overwrite ajax subscribe methode ?

5 Posts
2 Users
1 Reactions
799 Views
Posts: 4
Topic starter
(@abdeslam)
Active Member
Joined: 4 years ago

Hello,

Ā 

How to overwrite ajax subscribe methode ?

This code in themes/mytheme/wpforo/functions.php not work for me :

Ā 


remove_action( 'wp_ajax_wpforo_subscribe_ajax', ['Actions', 'subscribe'], 99 );
remove_action( 'wp_ajax_nopriv_wpforo_subscribe_ajax', ['Actions', 'subscribe'], 99 );

add_action('wp_ajax_wpforo_subscribe_ajax', 'my_subscribe', 999);
add_action('wp_ajax_nopriv_wpforo_subscribe_ajax', 'my_subscribe', 999);

function my_subscribe(){
...
}

Ā 

Thank you !

4 Replies
Chris
Posts: 3627
(@chris)
Famed Member
Joined: 3 years ago

Hi @abdeslam,

You have done almost right, you have written Action but didn't specify which namespace tag action.

3 Replies
(@abdeslam)
Joined: 4 years ago

Active Member
Posts: 4

Hi @chrisĀ 

Thank you for your reply.

this not work too. Help please !

Ā 

$myactions = new \wpforo\modules\subscriptions\classes\Actions();
remove_action( 'wp_ajax_wpforo_subscribe_ajax', [$myactions, 'subscribe'], 100 );
remove_action( 'wp_ajax_nopriv_wpforo_subscribe_ajax', [$myactions, 'subscribe'], 100 );

Thank you !

Ā 

Chris
(@chris)
Joined: 3 years ago

Famed Member
Posts: 3627

@abdeslam,

Check this:

add_action( 'wpforo_after_init_classes', function(){
    if( ! is_null( WPF()->sbscrb ) ){
        remove_action( 'wp_ajax_wpforo_subscribe_ajax',        [ WPF()->sbscrb->Actions, 'subscribe' ] );
        remove_action( 'wp_ajax_nopriv_wpforo_subscribe_ajax', [ WPF()->sbscrb->Actions, 'subscribe' ] );
    }
} );
(@abdeslam)
Joined: 4 years ago

Active Member
Posts: 4

@chrisĀ 

it's work with adding WPF()->sbscrb->Actions

thank you very much šŸ™‚