Registration page as homepage

You can create a shortcode for displaying a registration form and add it to a page or create a custom template with registration page layout. Once the page will be there, you can choose that page to display in home page from Setting >> Reading >> Front Page Display ( as in image ) From … Read more

Changing WordPress author name in database

Take a back up before trying anything! 🙂 (I use the Duplicator plugin for that, if you don’t already have a solution. When you delete users in WordPress, it gives the option to attribute conent to another user. Would this suit your needs?

List users by Year of Birth using a foreach loop to dynamically populate years and data

So, I solved this by doing a regular get_user() and putting it inside a for loop of years and ran the get_user on each year. $currentYear = date(‘Y’); $years = range($currentYear, 1900); foreach($years as $year){ $TotalArray = get_users(array(‘meta_key’ => ‘date_of_birth’, ‘meta_value’ => $year, ‘count_total’ => true, ‘meta_compare’ => ‘LIKE’, ‘role__in’ => ‘members’)); $thisYearsTotal = count($TotalArray); … Read more

Author permalink

What you need to do is make sure you have a unique base for your author permalinks. This sample code would do what you need. You may need to flush the rules after you include this code in your functions.php. A rewrite rules inspector plugin will help you get this all working smoothly: function wpse263881_init() … Read more

Grab user_id inside a function

Your function requires an input argument $user in order to work. If you simply call wp_user_id() without any argument it will return an error. The solution is giving $user a default value, making the argument optional. function wp_user_id( $user = NULL ) { // Give $user a default value of NULL if ( empty($user) ) … Read more

How to restrict Admin from creating new users from Add new user screen in dashboard to only of one domain?

You can hook into registration_error and check if the user’s email is under your specified domain or not: add_filter( ‘registration_errors’, ‘user_email_checker’, 10, 3 ); function user_email_checker( $errors, $sanitized_user_login, $user_email ) { if ( !preg_match(‘#[@.]gmail.com$#i’, $user_email ) { $errors->add( ‘invalid_email’, __( ‘ERROR: Only “gmail.com” email address allowed.’ ) ); } return $errors; } This way you … Read more

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