CodeWaggle
Forum Replies Created
-
Forum: Plugins
In reply to: [Nav Menu Roles] Sample Custom Role Code Shown in ReadmeHey that’s great, it’s even easier to customize than what I wrote!
Feel free to use anything I’ve posted, just makes the effort all the more worthwhile.
Joe
Forum: Plugins
In reply to: [Nav Menu Roles] Sample Custom Role Code Shown in ReadmeI was hoping that Dave would check back and see it, I just missed him by 10 minutes.
Hopefully someone else will find it helpful in the future.
Next time you do an update you could change the description to note that it’s very flexible.
This plugin lets you hide custom menu items based on user roles. So if you have a link in the menu that you only want to show to logged in users, certain types of users, or even only to logged out users, this plugin is for you.
In addition to user roles, you can customize the functionality by adding check boxes with custom labels using the “
nav_menu_roles
” filter and then use the “nav_menu_roles_item_visibility
” filter to check against whatever criteria you need. You can check against any user meta values (like capabilities) and any custom attributes added by other plugins.Forum: Plugins
In reply to: [Nav Menu Roles] Sample Custom Role Code Shown in ReadmeYou can use it for anything you want, including capabilities.
Here’s what I’m doing:
I make up names that I want to appear in the “Access Role” section of the menu item:function cwaga_new_roles( $roles ){ $roles['member'] = 'Member'; $roles['registered'] = 'Registered'; return $roles; } add_filter( 'nav_menu_roles', 'cwaga_new_roles' );
Then I write code that tells it what to do if my custom “role” is checked for that menu item. So you can write code that pulls the capabilities for the current user from the user_meta table and check if they have the capability that you want them to have. In my case I’m checking the users membership level, so my code gets their level and compares it based on my criteria.
function cwaga_item_visibility( $visible, $item ){ global $pmpro_ready; if( is_user_logged_in() && isset($pmpro_ready) ){ if( isset( $item->roles ) && is_array( $item->roles ) && in_array( 'member', $item->roles ) ){ global $current_user; $user_id = $current_user->ID; $cwjds_member_level_info = pmpro_getMembershipLevelForUser($user_id); if ( $cwjds_member_level_info->ID > 1 ){ $visible = true; } else { $visible = false; } } elseif( isset( $item->roles ) && is_array( $item->roles ) && in_array( 'registered', $item->roles ) ){ global $current_user; $user_id = $current_user->ID; $cwjds_member_level_info = pmpro_getMembershipLevelForUser($user_id); if ( isset($cwjds_member_level_info) && $cwjds_member_level_info->ID == 1 ){ $visible = true; } else { $visible = false; } } } return $visible; } add_filter( 'nav_menu_roles_item_visibility', 'cwaga_item_visibility', 10, 2 );
Forum: Plugins
In reply to: [Nav Menu Roles] Sample Custom Role Code Shown in ReadmeGlad to help,
JoeYour Welcome.
P.S.
Forgot to mention what a great plugin this is. I just came across it a few hours ago and it’s taken care of a conflict with the order that two plugins are loading (I was using a small function to change the priority, this is easier to keep track of).
Plus it’s taken care of the main goal which was to disable a plugin on a page where it was causing a conflict and isn’t needed.
Thanks!
Thanks for explaining the reason for the early priority, makes great sense.
Updating the priority via an action is a great option. It may be a little slower to let the shortcodes and such run, but my client will be happy that they can use widgets in the content area without messing with the plugin code each time it’s updated.
It occurs to me that because this isn’t a bug, it’s just cluttering up this forum.
I’m mark it resolved and move on.
Hi,
I understand that you may not consider this to be a problem with Paid Memberships Pro as using a widget to create the main content is unusual.
I’m thinking of manually changing the priority of the “add_filter(‘the_content’…” call so that I can use the two plugins together. Can you tell me if there is some problem that was resolved by using priority 5 for the call so that I can see if that will cause any problems with the way we’re using it?
I tried looking at the file history for the content.php file on GitHub, but the oldest version already has the priority set to 5, so I’m not able to see why it was set to 5.
I tried searching through the change log, but didn’t see anything that would seem to be a problem if I change the priority:
Searched for “priority”:
= 1.3.19 =
* Updated the priority of a few actions/hooks so the “besecure” https stuff gets run as soon as possible. Before it was possible that some URLs could be written out with http: on an HTTPS page before PMPro had a chance to fix things. You should have fewer SSL errors on the checkout page to deal with now.Searched for “the_content”:
= 1.5.2 =
* the_content filter removes any class=”more-link” class from the content if showing an excerpt.= 1.4 =
* Now applying “the_content” filters on the confirmation message on the confirmation page. e.g. wpautop will be run on the text to automatically add paragraphs.= 1.3.4 =
* Changed the membership shortcode to apply the_content filters to the return value instead of just wpautop. This allows shortcodes within that shortcode and other filters to be run on the content. (Let me know if issues arrise from this.)Thanks,
JoeI’ll close this thread and start a new one with a more accurate title.
It’s not a problem with the Black Studio TinyMCE Widget.
It’s a conflict between the Page Builder plugin and Paid Memberships Pro.
I’ll be posting the details of my test results soon.
Forum: Plugins
In reply to: [Breezing Forms] Can't add formForum: Plugins
In reply to: [Breezing Forms] Show/Hide Conditions on the Same Field?