Post comment as different user than logged in

Yes, add an user-select field in the comment form: add_action(‘comment_form_after_fields’, function(){ // allow only users who can moderate comments to do this if(!current_user_can(‘moderate_comments’)) return; $user = wp_get_current_user(); wp_dropdown_users(array( ‘name’ => ‘alt_comment_user’, ‘selected’ => $user->ID, )); }); When the form gets processed, check if an user has been selected and change the comment data before it … Read more

Change user’s display name programmatically

Just pasted your code into my functions.php with a different ID and checked the user’s page in /wp-admin/user-edit.php – it works, the value in Display name publicly as field is updated. Most likely something is wrong with your output on the user page. Check your template file. Or, if you can’t find the problem, edit … Read more

Importing users? From another wordpress site

I think you have two options (third if you find any plugins). I think if you export data from one WP, the users are also copied. The drawback is that you have to import all the content as well. The second option is to export the users from MySQL using PHPMyAdmin. Just export the user … Read more

How to display the names of users from a specific group with a shortcode?

Below is my own answer to the question. I will appreciate any constructive comment. add_shortcode( ‘group_members’, ‘group_members_shortcode_handler’ ); function group_members_shortcode_handler ( $atts, $content = null ) { global $wpdb; $querystr = “SELECT * FROM wp_groups_user_group”; $users = $wpdb->get_results($querystr, OBJECT); $output=””; foreach ($users as $user) { if($user->group_id == $atts[‘group_id’]){ $firstName = esc_html(get_user_meta($user->user_id, ‘first_name’, true)); $lastName = … Read more

‘username_exists’ still returns an ID even after deleting record from the database?

By default, WordPress uses $wp_object_cache which is an instance of WP_Object_Cache to save on trips to the database. Trace back username_exists() function, you will notice that get_user_by() uses WP_User::get_data_by() which return user data from $wp_object_cache immediately without checking if that user exists in database. Note that $wp_object_cache is stored in memory. It means that if … Read more

Add new user : make the fields First Name and Last name required

If you were looking to make the fields required in the WordPress admin form for adding new user as i understood from your question, where the output is not filterable, you could basically do what you described (adding form-required) on browser side function se372358_add_required_to_first_name_last_name(string $type) { if ( ‘add-new-user’ === $type ) { ?> <script … Read more

Post list based on the user that is logged in

there you go, i’m not the only one trying to bring back-end functionality to the front-end. anyway its not that hard go to your “USER DASHBOARD” template’s file and locate where the loop starts something like: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> and just above it paste this … Read more

Integrating WordPress to my website, while keeping my own authentication system

WordPress’s authentication system is made up of pluggable functions, which means that you can write a plugin that has a function named, say, wp_authenticate(), and your site will use your wp_authenticate() function instead of the native WordPress one. Your comment about is_user_logged_in() (on your original post) is obviated by the fact that is_user_logged_in() calls the … Read more

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