Tag Info

New answers tagged

1

Unfortunately, WordPress doesn't use a separate capability for previewing posts. A user needs the ability to edit a post in order to preview it. As seen in the WP_Query::get_posts() method: // User must have edit permissions on the draft to preview. if ( ! current_user_can($edit_cap, $this->posts[0]->ID) ) { $this->posts = array(); } What you ...


1

Arrrrg a WooCommerce question... quick burn him at the stake! There's a couple of problems with your callback function above: you are not declaring global $woocommerce so you do not have access to the $woocommerce global variable. and $woocommerce->customer holds the state of the WC_Customer class however this class does not contain a get_role() ...


0

First of all you need to remove capability edit_others_posts if assigned to vendor role. Then use the code snippet given below: function posts_for_current_author($query) { global $pagenow; if( 'edit.php' != $pagenow || !$query->is_admin ) return $query; if( !current_user_can( 'edit_others_posts' ) ) { global $user_ID; ...


0

I assume your WP settings is New User Default Role = contributor If yes, so this block of code shows all the contributor's with account_status = approved; $args = array( 'role' => 'contributor', 'meta_key' => 'account_status', 'meta_value' => 'approved' ); $users = get_users($args); foreach ($users as ...


0

Create a new plugin with the following code: class Facebook_Peeker { private static $facebook_bots = [ 'facebookexternalhit/1.1 (+https://www.facebook.com/externalhit_uatext.php)', 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)' ]; private $original_posts; public function ...


0

something like this : https://codex.wordpress.org/Function_Reference/add_role then if ( current_user_can('new_role') && !current_user_can('upload_files') ) add_action('admin_init', 'allow_new_role_uploads'); function allow_new_role_uploads() { $new_role = get_role('new_role'); $new_role->add_cap('upload_files'); }


2

The core functions: is_super_admin(), grant_super_admin(), revoke_super_admin() fetch the super admins data from the wp_sitemeta table with: $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); It's stored as a serialized array of user logins, for each site, like: a:1:{i:0;s:6:"louiev";} It's possible to override it with the ...


3

Here is an idea that you can implement. I think it will work just fine. Save the expiration time in user meta. Say the meta name is change_role. What you save in the meta is unix time. If you want to change them back in 14 days. Set the meta value to time() + 60 * 60 * 24 *14 code example update_user_meta($user_id, 'change_role', time() + 60 * 60 * 24 ...


0

What you're describing is likely best done in a simple WordPress plugin. You're user roles are already stored in WordPress, so a plugin to do this is likely only a few lines long. Also an existing plugin like File Away may accomplish what your attempting. This plugin surfaced when I did a plugin search for the terms... download directory based on ...


0

Using plugins like Paid Memberships PRO or s2member would be easiest solution for your purpose. You can create new user group and there capabilities. After that you can select which user group can see your post.


0

You can also use this : <?php if( current_user_can('editor') || current_user_can('administrator') ) { ?> // stuff here for admins or editors <?php } ?> For detailed reference check this another thread on stack. Thanks


2

You can use the set_user_role hook, that will only fire when the user role changes: add_action( 'set_user_role', function( $user_id, $role, $old_roles ) { // Your code ... }, 10, 3 ); If you want to restrict this to a profile update, you can use: add_action( 'set_user_role', function( $user_id ) { add_action( 'profile_update', function( ...



Top 50 recent answers are included