Blocking Administrative Access to Authors and Subcribers?

Create a functionality plugin and use this if you want to completely block the access to the Admin panel: /** * Hide the admin bar in the front end */ add_filter(‘show_admin_bar’, ‘__return_false’); /** * Redirects Authors and Subscribers to the site front page using: get_home_url() */ add_action(‘admin_init’,’block_users_wpse_53675′); function block_users_wpse_53675() { if( !current_user_can( ‘delete_pages’ ) ) … Read more

Updating User Meta with SQL Query

How can I write a bulk MySQL command to add in the value wp_capabilites=”a:1:{s:10:”subscriber”;b:1;}” into each user_id except 1, 2 and 3 ie. the newly imported users? You don’t. That is a serialized array which is a PHP construct. MySQL has no idea what to do with it. To the database, it is just an … Read more

Order users by custom user meta

Here’s the solution. Comments included: <?php $results = get_users(‘role=director’); foreach ($results as $result) { // Get data about each user as an object $user = get_userdata($result->ID); // Create a flat array with only the fields we need $directors[$user->ID] = array( ‘dir_order’ => $user->exit_director_order, ‘dir_id’ => $user->ID, ‘dir_name’ => $user->first_name.’ ‘.$user->last_name ); } // Sort sort($directors); … Read more

if role is logged in then do something

Something like this would be more efficient. This is basic PHP by the way, not WP specific. function add_extra_item_to_nav_menu( $items, $args ) { $roles = [ ‘administrator’ => [ //Role – slug name ‘SCHOOL_NAME-A’, //url path – appended to the end ‘ADMIN’, // can be any name – appended to SHOP NOW button ], ‘ROLEABC’ … Read more

Remove Ability for Administrators to Delete Administrators

Your question seems to boil down to this I can’t figure out how to check that the $userids in question are an administrators user ID. Try user_can($id,’administrator’) http://codex.wordpress.org/Function_Reference/user_can The Codex has a warning about using role names with the current_user_can function and it is very similar to user_can so I suppose caution is order until … Read more

how to make author to write comment on only his own posts?

I have the same thing running on my website. Here is how I do do it… Only post author and commentor can view each others comments function restrict_comments( $comments , $post_id ){ global $post; $user = wp_get_current_user(); if($post->post_author == $user->ID){ return $comments; } foreach($comments as $comment){ if( $comment->user_id == $user->ID || $post->post_author == $comment->user_id ){ … Read more

Roles at registration (classipress)

In your functions.php file do this: add_action(‘register_form’,’register_role_field’); add_action(‘register_post’,’check_fields’,10,3); add_action(‘user_register’, ‘register_role_fieldforuser’); // This will register new field in registration form function register_role_field(){ ?> <label>Choose your role:<br/> <!— Let’s check if there role already set. If $_GET[‘role’] = 0 -then this is teacher if 1 = student —> <?php if ( isset( $_GET[‘role’] ) ) { ?> … Read more

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