Show media-uploads to all users

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 … Read more

Add capability to a role , so user is only able to view his own posts

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; $query->set(‘author’, $user_ID ); } return $query; } add_filter(‘pre_get_posts’, ‘posts_for_current_author’); Above code allows … Read more

Let editors view post in admin but not be able to perform a save/edit

How about remove_meta_box( $id, $page, $context );? https://codex.wordpress.org/Function_Reference/remove_meta_box This will remove the Publish meta box which contains the save button… function disable_save() { if( !current_user_can( ‘edit_post’ ) ) { // Or whatever check you need to make remove_meta_box( ‘submitdiv’, ‘your-chosen-post-type’, ‘side’ ); } } // disable_save add_action( ‘admin_menu’, ‘disable_save’ );

Why current_user_can(‘edit_comment’) always true?

Notice how it is singular? Comment, not comments? This capability is not designed to check if user can edit any arbitrary comment out there. It can only check if user can edit one specific comment and correct way to call it is current_user_can( ‘edit_comment’, $comment_id ). Unfortunately second argument is missing from current_user_can() function signature … Read more

Query for user roles

You can check for specific user role using following code – if (is_user_logged_in() && current_user_can(‘administrator’)) {} The function current_user_can() takes role name as parameter. For more info – https://codex.wordpress.org/Function_Reference/current_user_can/

Show WordPress Plugin Menu(Admin) To Editor

Check these links below. This is where the permissions are being set for your pretty link plugin admin menu: pretty-link/prli-main.php -> line 16 – it’s set to administrator you want edit_posts pretty-link/prli-main.php -> line 160 – it’s set to $current_user->user_level >= 8 you want $current_user->user_level >= 7 What are your options? OPTION 1 – Change … Read more

How to change a user’s role depending on date registered?

Close, your date comparison is slightly off – user_registered will be a MySQL datetime, so your string comparison will never evaluate true. Instead, convert it to just the date: $registered = mysql2date( ‘Y-m-d’, $user->user_registered ); Now we’re talking: if ( ‘2015-10-01′ === $registered ) { // chocks away } Update: Here’s a complete snippet that … Read more

Let users edit their role from the frontend

You could make a widget that updates the role: Widget has a drop down select input Select input submits a Ajax call to backend Backend Ajax call processor updades the user meta Pass the User ID along with the role ID Update user meta with update_user_meta( $user_id, $meta_key, $meta_value, $prev_value )

Create a function to display HTML/data based on site admins role?

I think below line of code is unnecessary, which is wrong if you looking for logged in user result. if( ! is_user_logged_in() ) Please use below code, I make some changes for solution. //Add a hook for a shortcode ‘add_my_form’ tag… add_shortcode( ‘add_my_form’, ‘get_form_on_role’ ); //Create sortcode API used function… function get_form_on_role() { if(is_user_logged_in() ) … Read more

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