How to conditionally output to sidebar of each author’s archive and posts by each author?

As often the case, asking the question reveals the answer: Use global $authordata;. Fix php errors: == operator. Fix $rid=’445′, not $rid=445. Here’s the working code: add_action (‘genesis_before_sidebar_widget_area’,’user_testimonials’,10); function user_testimonials(){ if (is_author() || is_singular(‘post’)){ global $authordata; //using global $authordata is more direct $authorlogin = $authordata->user_login; //print_r( $authordata ); //to see everything if (is_author(‘author-1’) || ($authorlogin==”author-1″) … Read more

How to show user role in author.php

You can register a function in your functions.php like that: function get_user_role($id) { $user = new WP_User($id); return array_shift($user->roles); } Then in template file you call the function: <?php $aid = get_the_author_meta(‘ID’); echo get_user_role($aid); ?>

Display All Authors only

Use following code to get all users having role Author $args = array( ‘role’ => ‘author’, ‘number’ => ’10’, ); $authors = get_users( $args ); For all argument list refer this

Send email to author of post on post submission

The easiest way is to tie into the WordPress action publish_post. Here is a link to the codex with a basic example: https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post Note: If you are looking to do this for a Custom Post Type, you’ll need to add an action for publish_custom_post_type.

Display Recent Posts in BuddyPress Profile

This is quite easy, because you can use author as a parameter with get_posts(). The following snippet retrieves the 5 latest posts by a specific user, whose ID you need to pass. $author_ID = bp_displayed_user_id(); $author_posts = get_posts(‘author=”.$author_ID.”&posts_per_page=5′ ); if($author_posts) { foreach ($author_posts as $author_post) { // do output like echo $author_post->post_title.'<br />’ } }

Custom css author role

If a user is not logged in then admin_head probably won’t run. So let’s just check their capabilities. function my_custom_admin_head() { if ( ! current_user_can( ‘have-fun’ )) : ?><style> #welcome-panel{display: none !important;} #wp-content-editor-tools{display: none !important;} </style> <?php endif; // cant’ have-fun } add_action( ‘admin_head’, ‘my_custom_admin_head’ );

Display Authors Selectively

If I were you, I would avoid custom SQL if there are perfectly fine WordPress functions for your needs. Otherwise there’s a risk that you might leave vulnerabilities or backdoors to your database which might lead to complete loss/corruption of data in the future. Like any other query: the more arguments you use, the heavier … Read more

Get total post from an author

the_author_posts() doesn’t accept any parameters see the following codex page for more info: https://codex.wordpress.org/Function_Reference/the_author_posts#Parameters * UPDATED * Someone else had posted a VERY similar question. This should solve your problem: Show author post count in sidebar – Variable

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