0

I run a BuddyPress website and I need to deregister a script on a specific BuddyPress profile page (change avatar to be more specific)

To achieve this I try this code

add_action('wp_enqueue_scripts', 'cutting',100);
$uri = $_SERVER['REQUEST_URI'];
if(strpos($uri,'/members/'. the_author() .'/profile/change-avatar/') == true){
    function cutting() {
       wp_dequeue_script( 'bp-legacy-js' );
       wp_deregister_script( 'bp-legacy-js' );
    }
}

Unfortunatly it's not working :-(

Someone can help me on this one?

EDIT:

add_action('wp_enqueue_scripts', 'cutting',100);

function cutting() {
$uri = $_SERVER['REQUEST_URI'];
if(strpos($uri,'members/'. the_author() .'profile/change-avatar') == true){
   wp_register_style( 'connected4', get_stylesheet_directory_uri() . '/connected4.css' );
    wp_enqueue_style( 'connected4' );
}

}

I guess i must have a trouble with this part

if(strpos($uri,'members/'. the_author() .'profile/change-avatar') == true)
6
  • The logic should be inside the action callback and remember to prefix it to avoid possible name collisions.
    – birgire
    Sep 16 '15 at 0:55
  • Thank you Birgire however it's still not working I tried to enqueue a external stylesheet (more easy to see if snippet is workin) I edit my first post.
    – Neoseeyou
    Sep 16 '15 at 2:44
  • Are you sure the handle which you are using to dequeue and deregister does exist? I was checking on latest WordPress and BuddyPress plugin and could not find that handle in core. Please let me know which js file you want to remove? You can find the js file name from the page source when you are on change-avatar page. That would help me provide further inputs. Sep 16 '15 at 5:23
  • Note that the_author doesn't return the value, it just echos is @user1437654
    – birgire
    Sep 16 '15 at 8:10
  • Hello guys, thank you for your time! I want to deregister a script from a plugin because it make a conflict with avatar resize tool . Above code are juste exemple to check if my conditionnal is working. @birgire, i tried also if(strpos($uri,'members/'. the_author_meta('user_nicename') .'/profile/change-avatar') == true
    – Neoseeyou
    Sep 16 '15 at 19:10
0

Ok finally i find the solution using the bp_is_change_avatar

add_action('wp_enqueue_scripts', 'cutting',100);

function cutting() {
if(bp_is_change_avatar()){
   wp_dequeue_script( 'XXX );

}
}

Thank you everybody for your help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.