Show posts by author of membership level (Paid Membership Pro)

$ids = get_users( array(‘role’ => ‘author’ ,’fields’ => ‘ID’) ); $contr_limit = count($ids); for($cntr=0; $cntr < $contr_limit; $cntr++){ if( pmpro_hasMembershipLevel($level_id, $ids[$cntr] ) !== true ){ unset($ids[$cntr]); } } $args = array( ‘author’ => implode(‘,’, $ids), ‘orderby’ => ‘date’, ‘order’ => ‘ASC’, );

remove wp admin menu by customer user role

You can use wp_get_current_user() function to get current logged in user’s role //Remove admin menu items if not admin function remove_admin_bar_links() { global $wp_admin_bar, $current_user; $user = wp_get_current_user(); if ( in_array( ‘author’, (array) $user->roles ) ) { $wp_admin_bar->remove_menu(‘updates’); // Remove the updates link $wp_admin_bar->remove_menu(‘comments’); // Remove the comments link $wp_admin_bar->remove_menu(‘new-content’); // Remove the content link … Read more

Custom User role not working with custom post type

I thought I would try to clarify my comments: You only get a few things out of setting your capability_types the way you have above, which it is explained in Note 2 of capabilities. Here is what I see looking at $GLOBALS[‘wp_post_types’][‘adoptions’]->cap: stdClass Object( [edit_post] => edit_adoption [read_post] => read_adoption [delete_post] => delete_adoption [edit_posts] => … Read more

Shared account / dual blogging in WordPress

Yes, this is really very basic. If you are the admin, you can create new users and asign them a role. You could make your friend ‘author’, which would allow him to write and edit his own posts only, or make him an ‘editor’ if you also want him to edit other people’s post.

Allow only Admin role to access plugin settings/options page

The 3rd argument of add_options_page is the capability required for this page to be displayed to the user. Then to allow only admin to use this page, you have to set a capability which is only owned by admin, like activate_plugins. So change read to activate_plugins like this: add_options_page( ‘MyPlugin Options’, ‘MyPlugin Options’, ‘activate_plugins’, ‘myplugin-options’, … Read more

User restricted only show posts assigned to current user

You search certainly something like Members plugin. It allow you create a custom Role and You can make your site and its feed completely private if you want or just one or 2 posts. Its like you want. Or Manually, you can add new roles: function add_role() { add_role( ‘private_user’, “private user”,array( ‘is_able_to_read_private_page’=> true, ‘read’=> … Read more

Copy user role on multisite so the user can access subsites with same role

You can use the below function to copy all the users to all the subsite. It’s actually getting all the user IDs and subsites IDs first, then it’s looping over every sites and users to assign all the users to every subsite. Here is the updated code- add_action(‘wp’,’the_dramatist_add_current_user_to_site’); function the_dramatist_add_current_user_to_site() { global $wpdb; $all_users = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)