WordPress.org

Forums

User Submitted Posts
[resolved] usp_name (3 posts)

  1. usahai90
    Member
    Posted 1 year ago #

    I've turned off all of the fields because I wanted only the logged in user to be able to post. As such, I have turned off all the field inputs except Post Title and Post Content. However, after going through submission-form.php & user-submitted-posts.php, I have realized that it will only pass through the name if the field is activated. In the event that the field is deactivated, it defaults the name field to "admin". How can I change this to accept the default logged in credentials? Any help is greatly appreciated.

    https://wordpress.org/plugins/user-submitted-posts/

  2. usahai90
    Member
    Posted 1 year ago #

    Okay so I managed to fix a part of it. The parts in comments was the original code, and the code directly below is the part I added.
    user-submitted-posts.php:

    if (stripslashes($_POST['user-submitted-name']) && !empty($_POST['user-submitted-name'])) {
    			$author_submit = stripslashes($_POST['user-submitted-name']);
    			$author_info = get_user_by('login', $author_submit);
    
    			if ($author_info) {
    				//$authorID = $author_info->id;
    				$authorID = $current_user;
    				//$authorName = $author_submit;
    				$authorName = $current_user->user_firstname." ".$current_user->user_lastname;
    			} else {
    				//$authorID = $usp_options['author'];
    				$authorID = $current_user;
    				//$authorName = $author_submit;
    				$authorName = $current_user->user_firstname." ".$current_user->user_lastname;
    			}
    		} else {
    			//$authorID = $usp_options['author'];
    			$authorID = $current_user;
    			//$authorName = get_the_author_meta('display_name', $authorID);
    			$authorName = $current_user->user_firstname." ".$current_user->user_lastname;
    		}

    So what this is doing is passing the name as is in the account. However, when I view it on my site, I realize that it changes the meta user back to admin, but leaves the information as is. So $authorID in effect is returning "admin" when viewed from the admin account, but the $authorName is whatever account is sending the information. How can I retain the information of the $authorID in the administrator account?

  3. Jeff Starr
    Member
    Plugin Author

    Posted 11 months ago #

    I hope you figured this out, usahai90. Feel free to follow-up with any new infos.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • User Submitted Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.