Allow users with Editor role to edit menus (without a plugin)

Recently I had to tackle the same issue. Instead of setting the capability permanently for editors, I used user_has_cap filter to allow access dynamically. add_filter(‘user_has_cap’, ‘editor_allow_edit_menu’, 10, 4); function editor_allow_edit_menu($allcaps, $caps, $args, $user) { if ( ! isset( $allcaps[‘editor’] ) || true !== $allcaps[‘editor’] ) { return $allcaps; } global $pagenow; // new items are … Read more

Adding javascript trigger to user role selection on the user-edit page

You can use jQuery or plain javascript to add event listener to the role select element. E.g. jQuery(document).on(‘ready’, function(){ jQuery(‘select#role’).on(‘change’, function(){ // some if statement here alert(‘Role changed’); }); }); To add this to your admin you can either use admin_enqueue_scripts or admin_footer hooks. To enqueue script file, function my_admin_enqueue_scripts( $hook_suffix ) { if ( … Read more

How to display user order by role

i dont know how to achieve this in query arg. This is because it cannot be done using just arguments. No option for role is listed in the order/orderby parameter docs. There is no option to sort by user role in WordPress. Instead, you’re going to have to query for all gold role users, grab … Read more

Giving permission to anyone (non-users as well) with a password to edit a post, possible?

I would suggest having a generic form that can be completed by the public on the front end. The submission of the form would would generate the post, saving a random string in its meta data (the password), and send an email containing a link to /?p=PAGEID&post_id=THE_POST_ID&pw=THE_PASSWORD. THE_POST_ID and THE_PASSWORD are those values from the … Read more

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