Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #591641

    Hi I am using Enfold with a set of plugins including S2Member. The need is to display only selected portfolio items for each user in the welcome page of their capability level.

    For example: registered users A and B visit the website, register and are directed to the reg_user_welcome_page. There I would like A to see only the portfolio items which mach the username either via categories or tags.

    Do you have any suggestions?

    #593119

    Hey lipordu!

    Thank you for using Enfold.

    Create a page with the portfolio grid element then select all categories. After registration, redirect the users to this page. Add this in the function.php file in order to display item from a certain portfolio categories for a specific user:

    add_action('pre_get_posts', 'pre_get_posts_porfolio');
    function pre_get_posts_porfolio($query) {
    	if (!is_admin() && current_user_can('activate_plugins') && $query->query_vars['post_type'] == 'portfolio') {
    		$taxquery = array(
    			array(
    				'taxonomy' => 'portfolio_entries',
    				'terms' => array( 13 ),
    				'operator'=> 'IN'
    			)
    		);
    
       		$query->set( 'tax_query', $taxquery );
    	}
    }

    The code above will only display the items from the portfolio category with id 13 for users who can activate a plugin or admins.

    https://codex.wordpress.org/Roles_and_Capabilities
    https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts

    Cheers!
    Ismael

    #593189

    thanks Ismael, i will try asap and let you know the results

    lipordu

    #593483

    Hi!

    Please do so and let us know so we can mark the thread as resolved

    Regards,
    Yigit

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.