Notifications
Clear all

[Solved] How to overwrite ajax subscribe methode ?

5 Posts
2 Users
1 Likes
572 Views
Posts: 4
Topic starter
(@abdeslam)
Active Member
Joined: 3 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: 3650
(@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: 3 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: 3650

@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: 3 years ago

Active Member
Posts: 4

@chris 

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

thank you very much 🙂