How do I hide one menu item link for logged in and logged out users [closed]

A simple way to achieve that is to create two separate Navigation Menus (/wp-admin/nav-menus.php), and in your theme use the following: // Reference: // http://codex.wordpress.org/Function_Reference/is_user_logged_in // http://codex.wordpress.org/Function_Reference/wp_nav_menu if( is_user_logged_in() ) { wp_nav_menu( array( ‘theme_location’ => ‘logged-users’ ) ); } else { wp_nav_menu( array( ‘theme_location’ => ‘not-logged-users’ ) ); } Instead of theme_location, you can use … 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

Edit Post VS Custom Form

You are way on the safer and less effort involved side if having them access the admin interface is an option. In that case you could implement a custom post type for your needs, disable most of the ‘support’ flags when registering it, and add your own metabox to support latitude and longitude, as well. … Read more

How to get the ID of the currently logged in user?

get_current_user_id() effectively does what @Giri had described in the first snippet. The internal WordPress function-call chain eventually calls get_currentuserinfo() which already checks if there is a WP_User object, meaning a user is logged in. Thus, from what I can see in the linked code, get_current_user_id() always returns the ID of the user that is logged … Read more

Protect custom php file with login

This is impossible to answer definitively without a better description, but I am assuming that app.php is a completely distinct piece of code. In which case, WordPress can’t really manage access to it. You will need to incorporate it into WordPress. While this is not the only way to do it I would advise: Create … Read more

Only allow administrators and editors to access wp-admin

You’re correct in that you should be checking for a capability. However, manage options is only given to administrators by default. You should check against a capability that both editors and administrators have such as delete_others_posts. function restrict_admin(){ //if not administrator, kill WordPress execution and provide a message if ( ! current_user_can( ‘delete_others_posts’ ) ) … Read more

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