Skip to main content
Share Your Experience: Take the 2024 Developer Survey
14 votes

HTTPS leads to Sorry, you are not allowed to access this page

Just a quick note, the code define('FORCE_SSL_ADMIN', true); if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') $_SERVER['HTTPS']='on'; need to be at the top of the config file just after the <...
TheAlbear's user avatar
  • 241
9 votes
Accepted

How to get all capabilities of an existing user role

I suggest not to mess with the existing roles and capabilities in its default, it might help you some trouble when you will have a bunch of custom roles and capabilities in the future. To answer your ...
Mac organo's user avatar
5 votes
Accepted

How do I create a custom role capability?

Tested with WordPress 6.0, and it works: add_action( 'activated_plugin',function( $plugin,$network_activation ){ add_role( 'your_custom_role_slug', __( 'Your custom role title','your-plugin-domain'...
Jose's user avatar
  • 201
4 votes

Restrict admin access to certain pages for certain users

It won't let me comment, so I'm adding this as a new answer. The error: Warning: "call_user_func_array() expects parameter 1 to be a valid callback, >function 'exclude_pages_from_admin' not found ...
ben_jamin's user avatar
4 votes
Accepted

Hide Admin Menu for Specific User ID who has administrator Role

problem is with your logical statement. now you are trying to remove dashboard staff where user id is not '279', which means only user id 279 can see dashboard. you can try this in if statement if(...
Shamsur Rahman's user avatar
4 votes
Accepted

Can I create users that have access to *some* other users posts instead of all other users posts?

Here's my approach. Bear in mind that it covers the basic needs you've described but could be easily expanded into more robust solution. Few steps to follow (all code goes to your functions.php): 1. ...
Levi Dulstein's user avatar
4 votes
Accepted

Check if someone is editing a post (this content is currently locked)

Yes, there is a function in WP for that: wp_check_post_lock() Give it the post ID and it will return the user ID that is currently editing the post OR false if no one is editing the post (i.e. it is ...
butlerblog's user avatar
  • 4,996
3 votes
Accepted

How to change footer or <div> for different kinds of users in wordpress?

When a user is logged in, WordPress adds the class logged-in to the body tag, so you can target CSS differently for logged in users. body > footer { background: black; } body.logged-in > ...
Andy Macaulay-Brook's user avatar
3 votes

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 ...
Natan Zasepa's user avatar
3 votes
Accepted

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( ...
mukto90's user avatar
  • 1,354
3 votes

403 Forbidden - You don't have permission to access /wp-admin/admin-ajax.php on this server

This sounds like it's probably caused by mod-evasive (or similar) plugin in Apache (or similar), blocking multiple consecutive requests as it thinks you are trying to run a denial of service (DOS) ...
Ned Martin's user avatar
3 votes

WordPress password as plain text in email

No, WordPress passwords are not stored in plain text. They're stored as hashes generated by an old version of PHPass, which I think does multiple rounds of salted MD5 hashes. You cannot extract the ...
Rup's user avatar
  • 4,277
2 votes

One Site as a part of Multisite to be hidden (Un-published) from Public?

There are a few options for this: Premium Plugins: This works well to help multisite set ups hide sites and gives you a few ways to do it - but it is not free: https://premium.wpmudev.org/project/...
friendlyfire's user avatar
2 votes

How to remove "Super Admin" from All Users for those that are not a "Super Admin"?

This list of filters at the top of admin screens are called Views. You can manage views using the views_{$this->screen->id} filter. Where you'd replace {$this->screen->id} with the name ...
sxalexander's user avatar
2 votes

How to 'unpublish' or 'hide' posts when user role changes?

Interesting functionality, you will need something that does this: Will need to use the hook set_user_role to detect when user role change Then will need to query all posts from that user Then use ...
Bruno Cantuaria's user avatar
2 votes
Accepted

How to remove dashboard access (wp-admin) for author but not disable the capabilities?

Use this code in your functions.php file or in a plugin- function wpse_253580_prevent_author_access(){ if( current_user_can( 'author' ) && is_admin() ) { // do something here. ...
mukto90's user avatar
  • 1,354
2 votes

Show custom post type endpoint in REST API just if user has capability

The REST API has no parameters, options to solve this - in my opinion. But you should register only if the users have the capability in his role, like the follow example. add_action( 'rest_api_init', ...
bueltge's user avatar
  • 17.1k
2 votes

HTTPS leads to Sorry, you are not allowed to access this page

After changing the "Wordpress Address" and the "Site Adress" to https, and keeping FORCE_SSL_ADMIN set to true, I would make the http to https redirects occur above the code - so you're not relying on ...
David Sword's user avatar
  • 3,327
2 votes

HTTPS leads to Sorry, you are not allowed to access this page

This Really Worked for me in AWS, Amazon Linux 2 WordPress LAMP + Wordpress Added this Code at the top of the wp-config.php: <?php define('FORCE_SSL_ADMIN', true); if ($_SERVER['...
Sibi Paul's user avatar
2 votes
Accepted

how to add custom user capabilities using add_user_meta or something else?

Try passing the value without serializing it manually, because WordPress will do it for you anyway: add_user_meta( $user->id, 'orewpst_capabilities', array( 'author' => 1 ), true ); or ...
Felipe Elia's user avatar
2 votes

How can I access string value in an array?

If you're asking how to get those meta keys via WordPress, you can use the get_user_meta() - https://codex.wordpress.org/Function_Reference/get_user_meta get_user_meta( $user_id, 'tskypeid', true )
Welcher's user avatar
  • 3,588
2 votes

Can you have multi-site WP and keep users separate?

No, in a multisite, all sites have the same users table and user meta. Keep in mind if you did manage this though, it would be trivial for them to find out it was a multisite based on code, and they ...
Tom J Nowell's user avatar
  • 59.4k
2 votes

Limit user access to installing/configuring a plugin?

WP doesn't have a built-in way to restrict permissions this granularly. You can either install plugins, or not. For settings, it depends on where the plugin surfaces its settings. For example, if the ...
WebElaine's user avatar
  • 9,430
2 votes

Unique one time use URL

You could add a setting using add_option( 'access_keys', [ 'key_1', 'key_2 ] ) to check against when loading the page. add_action( 'init', 'wpse339612_check_access_codes' ); function ...
Ben Casey's user avatar
  • 356
2 votes

Can't access WordPress as an admin - but I can log in as a user!

You can check the user credentials in phpmyadmin by looking in the _usermeta table for a the meta_key column entry called wp_capabilities. Since you only have one user it will be the only entry. If ...
rudtek's user avatar
  • 6,121
2 votes
Accepted

if role is logged in then do something

Something like this would be more efficient. This is basic PHP by the way, not WP specific. function add_extra_item_to_nav_menu( $items, $args ) { $roles = [ 'administrator' => [ //...
vancoder's user avatar
  • 7,845
2 votes

MySQL query to list users who never signed in

What MySQL query can I use to get a list of users who have never logged in to WP? None. WordPress does not store this information so this is not something you can do, you would need to add code for ...
Tom J Nowell's user avatar
  • 59.4k
1 vote

remove/hide pages from users backend

One way to achieve this is by looping through the parent pages and fetching their respective children pages ids. The resulting arrays can then be merged and used in the 'post__not_in' variable. ...
Tunji's user avatar
  • 2,931
1 vote

How to remove dashboard access (wp-admin) for author but not disable the capabilities?

The above answer by Mukto90 is a little outdated. A better approach would be: Check capabilities instead of role name (current_user_can does support a role name but it's not guaranteed to work and ...
Elly Post's user avatar
  • 174

Only top scored, non community-wiki answers of a minimum length are eligible