Support » Plugin: User Posts Limit » Shortcode to display post limit based on user role

  • Resolved albyse

    (@albyse)


    Hi team, We are using your plugin. Thanks a lot for the plugin. We have a requirement. We want to show the post limit for each user role by passing user role as argument. Is there any way to show it? Because, there is a page in our website which lists all user roles and their post limit.

    Expecting your support. Thank you

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Condless

    (@condless)

    Hi,
    You can add the following code into your child theme’s functions.php file and use the shortcode [upl_role_limit role="author"]

    add_shortcode( 'upl_role_limit', 'wp_upl_role_limit_shortcode' );
    function wp_upl_role_limit_shortcode( $atts ) {
    	if ( isset( $atts['role'] ) ) {
    		$num_limit = get_option( 'upl_num_limit' );
    		$roles = get_option( 'upl_user_role' );
    		for ( $i = 0; $i < get_option( 'upl_rules_count' ); $i++ ) {
    			if ( $roles[ $i ] === $atts['role'] && isset( $num_limit[ $i ] ) && '' !== $num_limit[ $i ] ) {
    				return $num_limit[ $i ];
    			}
    		}
    	}
    	return __( 'No limit' );
    }
    
    Thread Starter albyse

    (@albyse)

    Thanks a lot for the code. It’s working

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcode to display post limit based on user role’ is closed to new replies.