2

I want to let members see their membership expiry date. I am running Civi 4.6 with Wordpress 4.4.1. I have tried creating a Membership Details profile with one field "Membership Expiration Date" in it, but whenever I try and view the field, I get "Profile search, view and edit are not supported for Profiles which include fields for more than one record type."

3

If you want to fetch this information directly, the following code should get you started. It displays the logged-in user's membership expiry date:

// get current WP user
$user = wp_get_current_user();

if ( civi_wp()->initialize() ) {

    // get contact ID
    require_once 'CRM/Core/BAO/UFMatch.php';
    $civi_contact_id = CRM_Core_BAO_UFMatch::getContactId( $user->ID );

    // get CiviCRM membership details
    $memberships = civicrm_api( 'Membership', 'get', array(
        'version' => '3',
        'page' => 'CiviCRM',
        'q' => 'civicrm/ajax/rest',
        'sequential' => '1',
        'contact_id' => $civi_contact_id,
    ));

    // show expiry date
    echo $memberships['values'][0]['end_date'];

}

Obviously your production code would include error checks after fetching the CiviCRM Contact ID and the Memberships that they may or may not hold. It would also convert the date to a more friendly format.

1

What other field types have you added to the profile? Can you add a screen shot of the fields you have included? If you have allowed access on the front end to the contact dashboard, you can include expiration date there, without having a separate profile.

enter image description here

0

Why not just use the User Dashboard and select which elements you want to show?

From the online CiviCRM Book:

When selecting the User Dashboard you get no additional options. To identify what related information you have setup to be displayed within the user dashboard i.e. Contributions, memberships, etc. navigate to Administer > Customize Data and Screens > Display Preferences and select all of the information you would like to have visible to the user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.