Remove Community Events Options from Admin Toolbar (Revisited)

Home Forums Calendar Products Events Calendar PRO Remove Community Events Options from Admin Toolbar (Revisited)

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #991551
    Eric Reynolds
    Participant

    Can you provide me the functions.php code mentioned but not displayed in an earlier forum topic?

    I would appreciate it as I would like to omit events from my admin toolbar for subscribers who are logged in.

    Thanks,

    🙂 Eric

    #991615
    Brian
    Member

    Hi Eric,

    I can help out here.

    This is the coding it referenced:

    https://gist.github.com/chriscct7/536711bf697b2935fe10

    Let me know if that works for you.

    Cheers

    #991621
    Eric Reynolds
    Participant

    Thank you Brian, I added the code to my child theme functions.php file and received the following error…

    Fatal error: Call to undefined function remove_menu() in /home/user/public_html/wp-content/themes/buddyboss-child/functions.php on line 63

    The offending code on line 63 is remove_menu(‘tribe-events’);

    🙂 Eric

    #991778
    Brian
    Member

    Hi,

    Ok sorry for that. I was not able to test it.

    I tried this out and got it to work:

    https://gist.github.com/jesseeproductions/475718b9155644e6070e

    That removes it for all roles, but the admin.

    Cheers

    #991809
    Eric Reynolds
    Participant

    No worries Brian. Thank you. The error is no longer there. However, one thing still remains. The “+ New” link with a dropdown that includes “Event”

    🙂 Eric

    #991814
    Eric Reynolds
    Participant

    Hi Brian, I found and implemented the following code in my child theme functions.php and it works. However, I would love to exclude admins. Is there something I can add to the code below that will omit admins from losing the “+New?”

    add_action( 'admin_bar_menu', 'remove_links_toolbar', 999 );
    
    function remove_links_toolbar($wp_admin_bar) 
    {
     global $wp_admin_bar;
     $wp_admin_bar->remove_menu('new-content');
    }

    UPDATE

    I found the following code to omit a user (admin) with ID “1” How can I add other user IDs to this code?

    function remove_links_toolbar($wp_admin_bar) 
    {
     global $wp_admin_bar, $current_user;
     if ($current_user->ID != 1) {
     	$wp_admin_bar->remove_menu('new-content');
     	}
    }
    • This reply was modified 10 years, 8 months ago by Eric Reynolds.
    #991961
    Brian
    Member

    Hi,

    Glad it is getting closer.

    Are you trying show the menus for all the admins, but that is it?

    Are they all admin roles?

    #992013
    Eric Reynolds
    Participant

    Yes. It would be great if I could display the calendar options in the toolbar for just admins. 🙂 Eric

    #992122
    Brian
    Member

    You can use this conditional to target everyone but admins:

    if(!current_user_can('manage_options')){

    }

    #992172
    Eric Reynolds
    Participant

    Thank you Brian. That did the trick! 🙂 Eric

    #992265
    Brian
    Member

    Great glad it helps.

    I am going to close this ticket, but if you need anything else related to this topic or another please post a new topic on the forum and we can help you out.

    Thanks

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Remove Community Events Options from Admin Toolbar (Revisited)’ is closed to new replies.