Tag Info

New answers tagged


You set a custom url after rewrite from a login. A small example, usable in a template of the theme to login. <?php $redirect = esc_url( 'your-url' ); if ( ! is_user_logged_in() ) { $link = '<a href="' . get_option( 'siteurl' ) . '/wp-login.php?redirect_to=' . home_url( '/' ...


Use add_role with any array of capabilities. Example: add_role( 'custom_role', 'Custom Role', array( 'read' => true ) );


Have you tried adding the unfiltered_upload capability too? function add_theme_caps() { // gets the author role $role = get_role( 'subscriber' ); $role->add_cap( 'upload_files' ); $role->add_cap( 'unfiltered_upload' ); } add_action( 'admin_init', 'add_theme_caps'); add_action( 'init', 'add_theme_caps');


The plugin you mentioned is only reportedly tested up to WordPress version 3.6.1. I would not (in general) recommend abandoned plugins, because they might impose security risks. Additionally it uses PHP4 class constructors, that might soon be deprecated and it calls non static methods in a static way. If you remove the plugin, you should be able to use ...


I have not tested but the following code will help you please add the following two lines of code to your function.php file $role= get_role([role_name ]); $role->add_cap('upload_files');


You can try this plugin https://wordpress.org/plugins/wordpress-access-control/ by using this plugin You can easily set a page to be accessible only by members of your site, or even a specific role


Try using below code to remove administrator and editor option from drop down. Use editable_roles filter function wdm_user_role_dropdown($all_roles) { global $pagenow; if( current_user_can('editor') && $pagenow == 'users.php' ) { // if current user is editor AND current page is user's listing page ...


You can try the map_meta_cap filter: /** * Uneditable posts/pages for editors */ add_filter( 'map_meta_cap', function ( $caps, $cap, $user_id, $args ) { // Edit to your needs: $post_ids = [123, 234, 345, 456]; // Uneditable posts $role = 'editor'; // Uneditable by this user role // Make given posts uneditable for the ...


I would try to display the meta using ACF like this : <?php $role = get_field('user_role', $profile_author); if( !empty($role) ): ?> <?php echo $role; ?> <?php endif; ?>


A new capability has to be explicitly added to either a role or a user. In your case if you want all administrators to have 'cap' capability you will add it to 'administrator' role: $role = get_role( 'administrator' ); $role->add_cap( 'cap' ); If you want a specific administrator only to have 'cap' capability then you add it to this particular user: ...


Just note that there is a simpler way to change the user role which is especially helpful when you do not know the current role of the user: ->set_role() Example: // Fetch the WP_User object of our user. $u = new WP_User( 3 ); // Replace the current role with 'editor' role $u->set_role( 'editor' );


How can I make the contributor rank able to publish an article but have it then require the approval of an admin before it actually gets published to the website? The "Contributor" role already behaves that way: Contributor delete_posts edit_posts read https://codex.wordpress.org/Roles_and_Capabilities#Contributor As you ...

Top 50 recent answers are included