Tips and Tricks HQ Support Portal › Forums › WP eMember › eMember and MyCred Plugin – show a page once to new (logged-in) member
Tagged: members, membership, mycred, points
- This topic has 7 replies, 3 voices, and was last updated 9 years, 11 months ago by jurgenvt.
-
AuthorPosts
-
October 6, 2014 at 11:40 am #11565jurgenvtMember
Hi, I have created a WP+buddypres+emamber site which works great.
one challange though.
all members get “points”when they become a member.
for this i am using the Mycred plugin [http://mycred.me]
i need some kind of page that is shown to a new (logged-in) member only once.
in this page (or function) i can do:
echo do_shortcode( ‘[mycred_give amount=”10″ log=”new membership points” ref=”newmember_points”]’ );
which will give the member 10 points.
is there a designated spot in the code where i can do this, or is there a setting i can show only once to an new logged-in member?
looking forward to your reply
edit: moderation of new members is required in this website, so i cannot log them in after registration right away.
October 6, 2014 at 10:42 pm #65861wzpModeratorThere really isn’t any support for “once only” display of content.
The closest thing I can think of is…
- They register to a “Welcome” membership level, that awards them their credits.
- You then use the eMember API to upgrade them to a “Working” membership level:
- Upgrading them prevents them from getting access to the previous “Welcome” level.
October 6, 2014 at 11:16 pm #65862adminKeymasterThe best way to do this is to use after registration hook so the points are awarded after the registration is complete. It doesn’t rely on a user visiting a page (that can always be tampered)
Here is a sample/example snippet of code to show you what I mean:
add_action('user_register', 'give_member_registration_points');
function give_member_registration_points($user_id)
{
$ref = "newmember_points";
$user_id = $user_id;
$amount = "10";
$log = "new membership points";
//Give points here
$mycred = mycred();
$mycred->add_creds(
$ref,
$user_id,
$amount,
$log
);
}October 8, 2014 at 12:22 pm #65863jurgenvtMemberHi admin,
this seems really promessing
where do i put this code
thank you so much!
October 8, 2014 at 10:57 pm #65864adminKeymasterYou can add that custom code to your functions.php file of the theme.
October 11, 2014 at 4:40 pm #65865jurgenvtMembersorry to bother again,
i seem to miss something, because when i put this in my functions.php
my website turns to white.
error log:
PHP Parse error: syntax error, unexpected T_VARIABLE in /…localpathhere…/functions.php on line 1394
code in functions.php
<?php
add_action('user_register', 'give_member_registration_points');
function give_member_registration_points($user_id) {
$ref = 'newmember_points';
$user_id = $user_id;
$amount = '10';
$log = 'new membership points';
//Give points here
$mycred = mycred();
$mycred->add_creds(
$ref,
$user_id,
$amount,
$log
);
}
?>i understand there must be something wrong with then $mycred variable , my skills ar not sufficient unfortunatly..
i know this beyond your support, but im trying anyway..
thank you
October 11, 2014 at 11:00 pm #65866wzpModerator$log = ‘new membership points’
There’s supposed to be a semicolon at the end of that line. I have edited your post and corrected the code.
October 12, 2014 at 7:01 pm #65867jurgenvtMemberi should have known that! thank you
and this works like a charm!, thank you so much!
problem solved!
-
AuthorPosts
- You must be logged in to reply to this topic.