Retrieve all users from wordpress database via REST/JSON API

Thanks to stackoverflow user Milap ! You can get all users even they have not created any post, for that you need to modify rest-api plugin. Open wp-content/plugins/rest-api/lib/endpoints/class-wp-rest-users-controller.php file, you will find below code on line number 106, if ( ! current_user_can( ‘list_users’ ) ) { $prepared_args[‘has_published_posts’] = true; } Change it to below, if … Read more

How to get the Gravityform entry ID from current user’s form submission? [closed]

You can use the gform_after_submission hook[1] to add the Entry ID (and probably the Form ID to minimize confusion if you have multiple forms) to the user’s meta information using add_user_meta(). <?php add_action( ‘gform_after_submission’, ‘wpse96468_map_user_to_entry’, 10, 2 ); // to tie it to a specific form, use the format below, // replacing ‘{$form_id}’ with the … Read more

Grouping users under parent user

Roles First of all you need to register the 2 roles, look at add_role. When you register the role, you are free to assign any capability you want. Only be careful to add the roles when your theme / plugin is activated and possibly remove them (see remove_role) when it is disabled. Meta Data You … Read more

Disable delete user

When you click on “delete”, the action ‘delete_user’ will be launched: https://core.trac.wordpress.org/browser/tags/4.4.1/src/wp-admin/includes/user.php#L313 After that you can check, if the user has written at least one ‘portfolio’ post. add_action(‘delete_user’, ‘sw_portfolio_check’); function sw_portfolio_check( $user_id ) { $result = new WP_Query( array( ‘author’=>$user_id, ‘post_type’=>’portfolio’, ‘posts_per_page’=>1, ) ); if ( count($result->posts) !== 0 ){ wp_die(“User has a portfolio and … Read more

Get the name of user who updated post

You can use the_modified_author(); See https://codex.wordpress.org/Function_Reference/the_modified_author <p>This post was last modified by <?php the_modified_author(); ?></p>

How to update the delete user confirmation form?

On the Users (wp-admin/users.php) page, WordPress uses wp_dropdown_users() to generate the users drop-down menu you’re referring to, so I’d suggest using the wp_dropdown_users_args hook to filter the users query, e.g. to show only 1 result (or 10, but surely not 55k!) and then use JavaScript to add/load the other results. So in this answer, I’m … Read more

How to paginate the get_users function?

First get the total number of users: $total_users = count_users(); //var_dump($total_users); //for debugging purpose $total_users = $total_users[‘total_users’]; and the current page: $paged = get_query_var(‘paged’); Set a variable that will decide how many users to display per page: $number = 20; // ie. 20 users page page Then, in your $args array add the offset if … Read more

Logout redirect to current page – function

Using this code in the functions.php does the trick: function wpse_44020_logout_redirect( $logouturl, $redir ) { return $logouturl . ‘&amp;redirect_to=’ . get_permalink(); } add_filter( ‘logout_url’, ‘wpse_44020_logout_redirect’, 10, 2 ); Note – The above code works only on non-admin pages. To make this work on any page you should replace: return $logouturl . ‘&amp;redirect_to=’ . get_permalink(); With: … Read more

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