set post author depending on condition via frontend post submit

The wp_insert_post_data filter is the right approach. I would do something like this: add_filter( ‘wp_insert_post_data’, ‘some_handler’ ); function some_handler( $data )//$data is an array of sanitized post data { //do some conditional checking… if ( ! isset( $_POST ) ) {//the request to insert post data wasn’t done by a user return $data; } //don’t … Read more

Can change twentytwelve_entry_meta “by-author” links?

Well for anyone who may be interested, I worked out that the answer, after adding the my_author_rewrite_rules function as above (thank you), is to edit the twentytwelve_entry_meta() function by replacing this: esc_url( get_author_posts_url( get_the_author_meta( ‘ID’ ) ) ), with this: esc_url( sprintf( __( home_url().’/author/%d’, ‘twentytwelve’ ), get_the_author_meta(‘ID’) ) ), It also means similarly changing the … Read more

How to reorder the content of the single post?

try this in functions.php function author_after_content($content) { if ( is_singular(‘post’) ) { $content .= “<p>بقلم : ” . the_author() . “</p>”; } return $content; } add_filter(‘the_content’, ‘author_after_content’, 20);

Authors divided alphabetically

This is what I ended up with. Totally does the trick, minus the sorting by last name. Would love to hear any additional thoughts on that. $display_admins = false; $order_by = ‘display_name’; // ‘nicename’, ’email’, ‘url’, ‘registered’, ‘display_name’, or ‘post_count’ $role=””; // ‘subscriber’, ‘contributor’, ‘editor’, ‘author’ – leave blank for ‘all’ $avatar_size = 32; $hide_empty … Read more

Display Authors avatars when more than one author

Here we go, found a nice thread which gave some answers and developed this which works a treat: if ( class_exists( ‘coauthors_plus’ ) ) { $co_authors = get_coauthors(); foreach ( $co_authors as $key => $co_author ) { $co_author_classes = array( ‘co-author-wrap’, ‘co-author-number-‘ . ( $key + 1 ), ); echo ‘<div class=”‘ . implode( ‘ … Read more

ACF Relationship – Exclude pages not created by author

If you want to exclude ALL pages that doese’t have ‘collaborator’ set as author, then you want to exclude all other pages in the site and include all pages of that author minus, maybe, some hand picked pages of that author, then I think you can use this: add_filter(‘acf/fields/relationship/query/name=products’, ‘exclude_id’, 10, 3); function exclude_id ( … Read more

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); ?>

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