• Resolved ricschug

    (@ricschug)


    I’m fairly new to WP and am not able to get the USP hook ‘usp_post_status’ to work. I simply want to set all user created posts to private when posted. Although WP and filters are new to me I have created other hooks that work just fine. I’m running the up to date USP plugin and have created a snippet as follows:
    /*
    *set usp post status to private
    */

    function set_post_status_private( $status) {
    $status = ‘private’;
    return $status;
    }

    add_filter( ‘usp_post_status’, ‘set_post_status_private’ );

    Is there something obvious that I’m missing? Thanks for any help provided.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Jeff Starr

    (@specialk)

    The logic of your code/function looks correct. The only thing that looks like it could be an issue are the curly quotes surrounding the hook and function names. I’m not sure if that is happening just here on your post, or if it is like that in the actual code on your site. Either way, you want to make sure to use only straight quotes never curly when writing code.

    Thread Starter ricschug

    (@ricschug)

    Jeff thanks for the fast response. The quotes are straight quotes. I didn’t think it would matter but just so you know I am using the Snippet plugin for all my hooks and filter as it make things much easier for a beginner. It appears that the hook is not firing.

    Plugin Author Jeff Starr

    (@specialk)

    Yes you are correct. After further investigation this appears to be a bug with the plugin. Will get it fixed up for the next plugin update. Thank you for reporting, @ricschug.

    Thread Starter ricschug

    (@ricschug)

    Thank you Jeff. I await the next release.

    Plugin Author Jeff Starr

    (@specialk)

    Just to follow up. The plugin is correct, there is no bug. It’s just that the wrong hook was used. Try this instead:

    function usp_set_post_status_private($postData) {
    	$postData['post_status'] = 'private';
    	return $postData;
    }
    add_filter('usp_post_data', 'usp_set_post_status_private');

    That will set all submitted posts to “Private” status.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘usp_post_status not working’ is closed to new replies.