• Resolved usahai90

    (@usahai90)


    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/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter usahai90

    (@usahai90)

    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?

    Plugin Author Jeff Starr

    (@specialk)

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘usp_name’ is closed to new replies.