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 display custom user meta from registration in backend?

Actually I found this to be more strait forward and simpler: //add columns to User panel list page function add_user_columns($column) { $column[‘address’] = ‘Street Address’; $column[‘zipcode’] = ‘Zip Code’; return $column; } add_filter( ‘manage_users_columns’, ‘add_user_columns’ ); //add the data function add_user_column_data( $val, $column_name, $user_id ) { $user = get_userdata($user_id); switch ($column_name) { case ‘address’ : … Read more

Show admin bar only for some USERS roles

You can disable the admin bar via function: show_admin_bar(false); So with that in mind, we can hook into after_setup_theme and hide the admin bar for all users except administrator and contributor: function cc_wpse_278096_disable_admin_bar() { if (current_user_can(‘administrator’) || current_user_can(‘contributor’) ) { // user can view admin bar show_admin_bar(true); // this line isn’t essentially needed by default… … Read more

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