How to Use Global Variables Inside Header and Footer

In functions.php you can create a constant with the user id, like this. // if somehow this constant exists this will prevent a php error if (!defined(‘CURRENT_USER_ID’)) { // if user is not logged it this constant will contain 0 define(‘CURRENT_USER_ID’, get_current_user_id()); } Now you have a constant variable available anywhere in your theme. To … Read more

No more administrator roles / permissions after WordPress upgrade

You can recreate the administrator role: wp –skip-plugins role create administrator Administrator wp –skip-plugins role reset administrator Restored 61 capabilities to and removed 0 capabilities from ‘administrator’ role. Success: Role reset. wp –skip-plugins user set-role YOURUSERNAMEHERE administrator

Associate multiple email addresses with the same user account, so they can log in with either

If you create them programmatically, you could set it up so that all of the usernames are one type of email address (business or personal) and the WP email address field contains the other type. It’s not clear if this would fit your particular use case, but one other login possibility is to integrate single … Read more

ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?

New answer I now have a better understanding of the question thanks to OPs comment and have come up with the following. Not tested! global $wpdb; /** * @var string $field The flexible content field name. */ $field = ‘a_flexible_content_field’; /** * @var string $layout The flexible layout name. */ $layout=”layoutTwo”; /** * @var string … Read more

Filter users in a search

Check the arguments for get_users() https://developer.wordpress.org/reference/functions/get_users/ What you should do is $users = get_users( array( ‘role__not_in’ => array( ‘administrator’ ) ) ) Then foreach ( $users as $user ) …