Is there a simple way to manage capabilities per user?

You don’t necessarily have to assign roles to manage the user’s capabilities. First, register your custom post types with their respective capabilities. See capabilities under Function Reference/register post type – Parameters Managing User Capabilities You can use add_cap or remove_cap to add or remove user capabilities for a specific user. // Add capability to a … Read more

Gravity Forms Submit form as another user

A solution I have found is to manipulate the entry after submission using the following: function submit_as_user_proxy( $form ) { $id = null; $proxy_user_meta = null; $user_role=””; $field_existing_users = null; $field_signed_up_as = null; foreach ( $form[‘fields’] as &$field ) { if ( false !== strpos( $field->cssClass, ‘existing_users’ ) ) { $field_existing_users = &$field; } if … Read more

Admins can’t edit each other’s posts

Ok, I got it figured out. For some reason, current_user_can was returning false when an admin went to edit other user’s posts… I have no idea how admins lost the ability to do this, but putting this into functions.php is a workable bandaid that restores admin edit capabilities; $administrator = get_role(‘administrator’); $administrator->add_cap(‘edit_others_posts’);

User fields that can be edited by administrator?

I used this so a teacher would mark what courses the students were subscribed to. This is a generic version of that code, using only one extra field. Admin view Other users view <?php /* Plugin Name: Admin User Fields */ add_action( ‘admin_init’, ‘wpse_70265_init’); function wpse_70265_init() { if( current_user_can( ‘administrator’ ) ) { add_action( ‘show_user_profile’, … Read more

Completely hide user info

This is dependant on your theme/plugins so it’s impossible to answer, as s_ha_dum mentioned. For example some themes output the author name in the body as a class like <body class=”author-keanu”> or maybe they just use the author id like <body class=”archive author-22″> and then you can check the author by going to www.example.com/?author=22 and … Read more

How to check that if current user (ID) has posts or not

Notice that your redirection must happen before the HTTP headers are sent out. You can try the following, where we place our logic inside the template_redirect hook callback (PHP 5.4+): /** * Redirect logged-in users to the admin dashboard * if the have written ‘student_form’ posts * else display [wpuf_form id=”414″] */ add_action( ‘template_redirect’, function() … Read more

wp_insert_user is not working for me?

The problem is from wp_insert_user and the fact that your value for user_pass is empty. You should update your code as so $random_password = wp_generate_password(8,false); $user_data = array( ‘user_login’ => $first_name, ‘user_pass’ => $random_password, ‘user_email’ => $trainer_email, ‘first_name’ => $first_name, ‘last_name’ => $last_name, ‘role’ => ‘trainer’ ); And remove this line wp_set_password($random_password, $user_id); You should … Read more