How to change image’s author via a function when using GravityForms uploader? [closed]

add_action(“gform_user_registered”, “image_author”, 10, 4); function image_author($user_id, $config, $entry, $user_pass) { $post_id = $entry[“post_id”]; $args = array( ‘post_parent’ => $post_id, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’ ); $attachments = get_posts($args); if($attachments) : foreach ($attachments as $attachment) : setup_postdata($attachment); $the_post = array(); $the_post[‘ID’] = $attachment->ID; $the_post[‘post_author’] = $user_id; wp_update_post( $the_post ); endforeach; endif; }

Author page points to 404 error page

The user_nicename should never have spaces. It is a sanitized version of user_name, that has been sanitized (Aa-Zz,0-9,_,-) to be suitable for use as a slug. If you have spaces in your user_nicename values, you’re going to get 404 errors. To correct, you’ll probably need to edit the database directly. Here are instructions, with screenshots, … Read more

Authors’ Links on Homepage Not Going to Author Post Pages

The code below is the correct code, in several different PHP files. Currently need to know how to write it using the the_author_posts_link(); <p class=”postAuthor”>By <a href=”https://wordpress.stackexchange.com/questions/74001/<?php the_author_meta(“user_url’); ?>”><?php the_author(); ?></a></p> Just replace this: <a href=”https://wordpress.stackexchange.com/questions/74001/<?php the_author_meta(“user_url’); ?>”><?php the_author(); ?></a> With this: <?php the_author_posts_link(); ?> Alternately, you could use this: <a href=”https://wordpress.stackexchange.com/questions/74001/<?php echo get_author_posts_url(get_the_author_meta(“ID’ )); … Read more

post author if statement

The get_posts() function retrieves posts from the database. If I understand you correctly, that’s not what you want though, you simply mean to check the author of the post currently displayed. You can simply use $post->post_author. If outside the Loop, you have to call upon the $post global first. Hence global $post; // only required … Read more

Can’t change author to myself after post published

I guess you need administrator permissions to change the authors or modify the user role permissions. WordPress allows changing the post author only to a super-admin or a user with the right to edit others posts. Also, an editor only has these permissions

Display all authors in a theme template

What you need here is to shuffle all the array elements & then display them. But since php’s shuffle() function doesn’t preserve array key associations, here’s a version that does. function shuffle_assoc(&$array) { $keys = array_keys($array); shuffle($keys); foreach($keys as $key) { $new[(string)$key] = $array[$key]; } $array = $new; return true; } Add this function somewhere … Read more

How can i list random author?

The Codex lists rand as the orderby string, not RAND. I suspect that either works but I haven’t checked. But that isn’t how I’d do this. I’d lean toward something like… $current_category_ID = getCurrentCatID(); $current_cat_id = $current_category_ID; $author_array = array(); $args = array( ‘numberposts’ => -1, ‘cat’ => $current_cat_id ); $cat_posts = get_posts($args); foreach ($cat_posts … Read more

how can authors to define custom pages?

You can do the following: <?php $post = $wp_query->post; $options = get_option( ‘sample_theme_options’ ); $authors = explode( ‘,’, $options[‘sometext’] ); if ( is_author( $authors ) ) { include ( TEMPLATEPATH . ‘/brand.php’ ); } else { include ( TEMPLATEPATH . ‘/customauthor.php’ ); } ?> This way, you’re always sure that $authors contains an array.

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