Support » Plugin: Ultimate Member - User Profile & Membership Plugin » my_after_profile_header_name_args add trext if condition is ok

  • Resolved calle81

    (@calle81)


    Hi I would like to insert a text in um_after_profile_header_name_args only if the variable of the value of the meta key “seisvincolato” of the profile id is equal to Yes. I tried to write this code but it does not work. If I do an echo of $ricercasquadra, it shows me a text “array”.

    add_action( 'um_after_profile_header_name_args', 'my_after_profile_header_name_args', 10, 1 );
    function my_after_profile_header_name_args() {
           $profileident = um_profile_id();
    $ricercasquadra = get_user_meta( $profileident, 'seisvincolato', true );  
        if ( $ricercasquadra ==  'Si' ) {	
      echo "<span class='cerchionotred'><font color='white'><b> SEARCH TEAM </b></font></span>"; 
            }
    }

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @calle81,

    You should use the action hook um_after_profile_header_name instead of um_after_profile_header_name_args.

    Let us know if this helps you.

    Regards,

    @champsupertramp Thanks for the reply. It doesn’t work, keep returning “array” and not the value of the meta key “svincolato” for compare it with the if function.

    add_action( 'um_after_profile_header_name_args', 'my_after_profile_header_name_args', 10, 1 );
    function my_after_profile_header_name_args() {
           $profileident = um_profile_id();
    $ricercasquadra = get_user_meta( $profileident, 'seisvincolato', true );  
        if ( $ricercasquadra ==  'Si' ) {	
      echo "<span class='cerchionotred'><font color='white'><b> SEARCH TEAM </b></font></span>"; 
            }
    }

    If I do echo $profileident returns the id of the profile I’m looking at.
    If I do echo $ricercasquadra, it display “Array” and not the value.

    Thanks.

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi,

    Could you please try dumping the variable $ricercasquadra with print_r or var_dump? Let us know the results.

    Regards,

    @champsupertramp Thanks for the reply.

    $ricercasquadra is a radio field in my form profile “si” and “no”.

    With var_dump($ricercasquadra); the result is:

    array(1) { [0]=> string(2) “Si” } with $profileident = 2

    array(1) { [0]=> string(2) “No” } with $profileident = 3

    thanks.

    • This reply was modified 2 months, 3 weeks ago by  calle81.
    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi,

    Please try the following code:


    add_action( ‘um_after_profile_header_name_args’, ‘my_after_profile_header_name_args’, 10, 1 );
    function my_after_profile_header_name_args() {
    $profileident = um_profile_id();
    $ricercasquadra = get_user_meta( $profileident, ‘seisvincolato’, true );
    if ( isset( $ricercasquadra[0] ) && $ricercasquadra[0] == ‘Si’ ) {
    echo “<span class=’cerchionotred’><font color=’white’><b> SEARCH TEAM </b></font></span>”;
    }
    }
    Hope this helps you.

    Regards,

    • This reply was modified 2 months, 3 weeks ago by  Champ Camba.
    • This reply was modified 2 months, 3 weeks ago by  Champ Camba.
    • This reply was modified 2 months, 3 weeks ago by  Champ Camba.
    • This reply was modified 2 months, 3 weeks ago by  Champ Camba.
    • This reply was modified 2 months, 3 weeks ago by  Champ Camba.

    @champsupertramp Perfect 🙂 !!

    Thanks.

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