Home › Forums › Front End PM PRO › Remove “New Announcement” Link from Menu
- This topic has 7 replies, 2 voices, and was last updated 5 years, 6 months ago by Shamim Hasan.
- AuthorPosts
- June 9, 2020 at 10:09 pm #38392Jeff AdanacParticipant
Hi there, I’m trying to remove the “New Announcement” menu link in the front-end for users without manage options privs but the following function seems to remove the whole menu rather than just that menu link. I’ve tried variations of the “New Announcement” condition (‘new_announcement’,’New Announcement’, etc) but all seem to make the whole menu disappear. Any recommendations would be wonderful! thanks
add_filter( 'fep_menu_buttons', 'fep_cus_fep_menu_buttons', 99 ); function fep_cus_fep_menu_buttons( $menu ) { if( ! current_user_can('manage_options') ){ unset( $menu['New Announcement'] ); return $menu; } }[MODERATOR] – Keep code between backtick
June 10, 2020 at 12:08 am #38395Shamim HasanKeymasterBy default “New Announcement” button is visible only to admins. No code require.
Let me know if this is not the case for you.June 10, 2020 at 2:29 am #38397Jeff AdanacParticipantThanks for your reply Shamim! Actually I’m looking to allow non-admin users with manage_options caps to see the “New Announcement” button and be able to create new announcements. All other roles (except) admin need to be prevented from doing so. Can you recommend a way to do this?
Thanks so much!
June 10, 2020 at 12:26 pm #38422Shamim HasanKeymasterUsers with manage_options capability are admin. They should see that button not the other users.
Did you logged in as any other user (who does not have manage_options capability) and see if you see that button?June 10, 2020 at 7:36 pm #38426Jeff AdanacParticipantThanks Shamim! Yes that’s what I was hoping to be the case but my issue is that my function above makes the whole menu disappear, rather than just the “New Announcement” menu button. Can you see anything wrong with my function that might cause this?
June 10, 2020 at 8:06 pm #38430Shamim HasanKeymasterYes, your code is not returning anything if user do not have manage_options capability. Use like following
add_filter( 'fep_menu_buttons', 'fep_cus_fep_menu_buttons', 99 ); function fep_cus_fep_menu_buttons( $menu ) { if( ! current_user_can('manage_options') ){ unset( $menu['new_announcement'] ); } return $menu; }June 10, 2020 at 9:16 pm #38434Jeff AdanacParticipantThat worked! a misplaced close on the if statement. Rookie mistake. Thank you very much. Another question, is there a way to filter the list of recipient roles to ‘subscribers’ only when creating a new announcement?
June 11, 2020 at 11:18 am #38439Shamim HasanKeymasterYes possible. Please follow https://sp-test1.arogga.co/support/topic/restrict-which-rolls-show-up-on-front-end-for-announcement/#post-25048
- AuthorPosts
You need to purchase ‘Front End PM PRO’ to create topic in this support forum.
If you already purchased ‘Front End PM PRO’ please LOGIN.