Disable user profile editing for one user

If you want to completerly remove the possibility for an user to access on profile, you can Give admin possibility to choose which user can access on profile and which not Remove the profile link from menu and from admin bar Ensure the profile is not accessible even if accessed directly by manually typing address … Read more

current user can edit user?

Yes it can be good practice to check if a user is capable of doing something before doing something related in code. For example, don’t save a custom post type if the user doesn’t have the capabilities needed to do it, or don’t show certain things to users who don’t have the manage_options capability ( … Read more

How can i create an array user meta?

As noted at the codex page for get_user_meta(): NOTE If the meta value does not exist and $single is true the function will return an empty string. If $single is false an empty array is returned. So I would suggest to do the check like this: ! empty( $themeta ) Regrading your other question, you … Read more

Call to undefined function wp_insert_user()

You need to make the functions available, they are located in wp-includes/user.php. So load the user.php via require e.g. like this: require( ABSPATH . WPINC . ‘/user.php’ ); But keep in mind, if you need to do that and load wp-load.php manually, then you likely have not done it right. Meaning, you should aim for … Read more

How can I allow users to sign up but prevent them from accessing the WordPress backend?

Check for administrator user current_user_can ( ‘manage_options’ ) Remove the admin bar for non-administrators show_admin_bar ( false ) Redirect non-administrators to another page wp_redirect ( site_url( “https://wordpress.stackexchange.com/” ), 302 ) Putting it all together function wpse_20160318_user_checks() { // ignore administrators if ( ! current_user_can( ‘manage_options’ ) ) { // ignore these events if (( defined( … Read more

Hide everything on site for visitors except specific page IDs

If you want to show a message, use this code in your functions.php file- function se_236335_hide_content( $content ){ $pages = array( 8, 26, 35 ); // allowed page IDs if( ! in_array( get_the_id(), $pages ) ){ return ‘Message here..’; } return $content; } add_filter( ‘the_content’, ‘se_236335_hide_content’ ); If you want a page redirection, use this- … Read more

Log all users out of all locations after 24 hours

There are few ways to accomplish what you want. I won’t give you any use-ready solution but just an idea. First idea You could set up cron job to replace authentication keys in wp-config.php, you can get them over here https://api.wordpress.org/secret-key/1.1/salt/ This way you will force all of the users to log in again. Second … Read more