Support Forum

Add an action button/link for each post

YE Yehonal
Yehonal
Member

Hi simple-press community. 

I’m looking for a way to add contents programmatically to a post/reply. I need something like a button , visible by administrators, that redirects to the mycred_edit_balance admin page where i can “adjust”arbitrarily the amount of mycred points for the post/reply author.

Is there any action/filter that i can use to add such functionality?

should i use child theme instead?

Thank in advance

4 Answers

New Answer

IK Ike
Ike
Member

Hey Yehonal,

Unfortunately this is a bit beyond my knowledge so will have to wait for Steve or Andy – Being a weekend and a public holiday in the States time is a bit scarce but hopefully one of them will be around soon.

MP Mr Papa
Mr Papa
Member

not entirely sure I follow what you want to do… you just want to add a button that links to a mycred page?

if so, have you looked at:  https://simple-press.com/documentation/codex/api/template-functions-and-the-api/display-template-functions/common-view/sp_addbutton/

lets you add a standard button linking to where ever you want…

if you only want it shown to admins, then something like:

if ($spThisUser->admin) sp_AddButton();

of course, adjust arguments to the function call to meet your needs…

If this is not what you meant, please elaborate…

YE Yehonal
Yehonal
Member

Thank you very much!

It’s exactly what i was looking for. It is the button i’ve created using an action :

 add_action('sph_BeforeSectionEnd_action', function() {
 global $spThisPost,$spThisUser;
 
 if ($spThisUser->admin) {
 sp_AddButton(sp_AddButton('tagClass=spButton spRight&icon=sp-logo-tiny.png&link='.urlencode('/wp-admin/users.php?page=mycred-edit-balance&user_id='.$spThisPost->user_id.'&ctype=mycred_default'), __('Adjust Points'), __('Adjust Points for this user'), 0, 'spLogoButton'));
 }
});
YS Yellow Swordfish
Yellow Swordfish
Member

That’s  great news. Excellent use of the tag and glad it managed to get you what you wanted. Thanks for letting us know.