Support » Plugin: Simple Membership » Display a key icon before the title of a membership post

  • Resolved kurousa007

    (@kurousa007)


    Hello. from Japan.
    I use the great Simple Membership, but I am having trouble getting the status of the user from your plugin.
    Like topic titles, I want to display “font awesome” of the titles.

    I wrote this in function.php

    function my_the_title($title, $id) {
    	global $wpdb;
    	$query = "SELECT * FROM " . $wpdb->prefix . "swpm_members_tbl WHERE member_id = %d";
    	$level_id = $wpdb->get_row($wpdb->prepare($query, $member_id));
    	if(  ){//simple membership login & protection
        return '<i class="fas fa-unlock-alt"></i>'.$title;
    	}elseif(  ){//simple membership NOT login & protection
    		    return '<i class="fas fa-lock"></i>'.$title;
    	}else{//NO protection
    				return ''.$title;
    	}
    }
    add_filter('the_title', 'my_the_title', 10, 2);
    

    How should I write the conditions?
    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support mbrsolution

    (@mbrsolution)

    Hi, thank you for reaching out to us. I have submitted a message to the developers to investigate further your issue/ request.

    Kind regards

    Thank you for your reply.
    I was able to complete.

    This allows you to see the public and private pages from the icon in front of the title.

    function my_the_title($title, $id) {
    	$protected = SwpmProtection::get_instance();
    	$auth = SwpmAuth::get_instance();
    	if($auth->is_logged_in() && $protected->is_protected($id)){
    		//simple membership login & protection
        return '<i class="fas fa-unlock-alt"></i>'.$title;
    	}elseif($protected->is_protected($id) && !$auth->is_logged_in() ){
    		//simple membership NOT login & protection
    		    return '<i class="fas fa-lock"></i>'.$title;
    	}else{//NO protection
    				return ''.$title;
    	}
    }
    add_filter('the_title', 'my_the_title', 10, 2);
    

    Kind regards

    Plugin Support mbrsolution

    (@mbrsolution)

    Hi, thank you for sharing your solution 🙂 I am sure this will help others wanting to achieve the same result as you.

    I will mark this support thread as resolved.

    Kind regards

    Plugin Author wp.insider

    (@wpinsider-1)

    Nice! I will add this to the tweaks page. Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display a key icon before the title of a membership post’ is closed to new replies.