How to add custom user role into wordpress

Example: add_role(‘student’, __( ‘Student’), array( ‘read’ => true, // Allows a user to read ‘create_posts’ => false, // Allows user to create new posts ‘edit_posts’ => false, // Allows user to edit their own posts ‘edit_others_posts’ => false, // Allows user to edit others posts too ‘publish_posts’ => false, // Allows the user to publish … Read more

Change a subsite Admin role of a WordPress Multisite after 24 hours registering

You probably want the built-in cron scheduler. You’ve got two options: either set up a one-off job to downgrade the user 24 hours after registering using wp_schedule_single_event() instead set up a daily job with wp_schedule_event() to check all blogs for users without KYC data and deactivate them if necessary. You should probably change your code … Read more

Sorting Users page admin column with ACF field

You can use the “pre_user_query” filter hook to modify the query that retrieves the users. Here’s an example code that how to sort the Users page admin column with an ACF field named. function sort_users_by_acf_field( $query ) { if ( ! is_admin() ) { return; } if ( isset( $query->query_vars[‘orderby’] ) && ‘user_company_name’ === $query->query_vars[‘orderby’] … Read more

AJAX call not initializing for non-admins in WordPress

There are several potential reasons for this issue: Permissions: Non-admin users may not have the necessary permissions to access the admin-ajax.php file, which is being called in your AJAX request. Make sure that the required permissions are set for the user roles other than admin. Authentication: Non-admin users may not be authenticated to access the … Read more

How to handle WordPress account for terminated employee

In general, an account for an employee that has ‘moved away’ (for any number of reasons) should have their access privileges immediately downgraded. I would also change their password to prevent access. There are many instances of a former employee still having access, and doing improper things to the business computer systems. When an employee … Read more

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